<template>
<div class="ui-modal" role="dialog" v-el:modal>
	<div>
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title">确认商户编号</h4>
				</div>
				<div class="modal-body">
					<form-group title="商户编号" :left="left">
						<select class="form-control" name="mchtIdFlag" v-el:id @change="watcher">
								<option v-for="item in mainList" :value="item.key">
									{{item.value}}
								</option>
							</select>
					</form-group>
				</div>
				<div class="modal-footer text-center">
					<v-button theme="primary" @click="resolve">确认</v-button>
				</div>
			</div>
		</div>
	</div>
</div>
</template>
<script>
export default {
	props: {
		mainList: {
			type: Array
		},
		left: {
			type: String,
			default: function() {
				return "3"
			}
		}
	},
	methods: {
		watcher() {
			let data = this.get();
			this.$dispatch("mid-watcher", data);
		},
		get() {
			return this.$els.id.value;
		},
		init() {
			$(this.$els.modal).modal('show');
		},
		hide() {
			$(this.$els.modal).modal('hide');
		},
		resolve() {
			let id = this.get();
			localStorage.setItem('get_id', id)
			this.hide();
			this.$dispatch("selected", id);
		},
		reject() {
			this.hide();
		}
	},
	beforeCompile() {
		let list = JSON.parse(localStorage.getItem('list_mid'));
		// this.$set("mainList", list);
	},
	ready() {
		// if (this.mainList.length > 1 && !localStorage.getItem('get_id')) {
		// this.init()
		// }
	}
}
</script>
